﻿/**********************************************************************
* @file   FITKAcousticsSEAJunctionMgrAdaptor.h
* @brief  交界处耦合管理器数据 读写适配器
* @author yangjing (1195810980@qq.com)
* @date   2025-02-25
*********************************************************************/
#ifndef _FITFK_ACOUSTICS_SEA_JUNCTION_MGR_MODEL_ADAPTOR_H___
#define _FITFK_ACOUSTICS_SEA_JUNCTION_MGR_MODEL_ADAPTOR_H___

#include "FITKAcousticsAbstractAdaptor.h"
#include "FITK_Kernel/FITKCore/FITKCoreMacros.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"
#include <H5Cpp.h>

namespace IO {
    class FITKHDF5FileTool;
}

namespace Acoustics{
    class FITKSEAJunctionPoint;
    class FITKSEAJunctionLine;
    class FITKSEAJunctionArea;
    class FITKSEAAbstractJunction;
    class FITKJunctionManager;
    struct FITKSEAJunAreaLeakStr;
}
namespace IO
{
    class FITKAcousticsHDF5IOAPI FITKAcousticsSEAJunctionMgrAdaptor : public FITKAcousticsAbsAdaptor
    {
    public:
        explicit FITKAcousticsSEAJunctionMgrAdaptor();
        virtual ~FITKAcousticsSEAJunctionMgrAdaptor() = default;

        virtual bool adaptR() override;

        virtual bool adaptW() override;

        /**
        * @brief 传入Junction数据用于该适配器使用
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  p   SubSysShell
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-15
        */
        void setData(Acoustics::FITKJunctionManager*JunctionManagerP);

    private:
        /**
        * @brief 写JunctionPoint点连接数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  subP  要写入的数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-15
        */
        bool writeJunctionPoint(H5::Group &gp, Acoustics::FITKSEAJunctionPoint *subP);


        /**
        * @brief 读JunctionPoint点连接数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  mager  junction管理器
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-15
        */
        bool readJunctionPoint(H5::Group & gp, Acoustics::FITKJunctionManager*mager);

        /**
        * @brief 写JunctionLine线连接数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  subP  要写入的数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-15
        */
        bool writeJunctionLine(H5::Group &gp, Acoustics::FITKSEAJunctionLine *subP);

        /**
        * @brief 读JunctionLine线连接数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  mager  junction管理器
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-15
        */
        bool readJunctionLine(H5::Group & gp, Acoustics::FITKJunctionManager*mager);


        /**
        * @brief 写JunctionArea面连接数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  subP  要写入的数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-15
        */
        bool writeJunctionArea(H5::Group &gp, Acoustics::FITKSEAJunctionArea *subP);

        /**
        * @brief 读JunctionArea面连接数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  mager  junction管理器
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-18
        */
        bool readJunctionArea(H5::Group & gp, Acoustics::FITKJunctionManager*mager);
    private:

        /**
        * @brief 写JunAreaLeakStr数据,该数据为面连接数据中的特有数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  Leaks  要写入的数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-18
        */
        bool writeJunAreaLeakStr(H5::Group &gp, QList<Acoustics::FITKSEAJunAreaLeakStr> &Leaks);

        /**
        * @brief 读JunAreaLeakStr数据,该数据为面连接数据中的特有数据
        * @param @param[i]  gp hdf5组别
        * @param @param[out]  data  传出数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-18
        */
        bool readJunAreaLeakStr(H5::Group &gp, QList<Acoustics::FITKSEAJunAreaLeakStr>&data);


        /**
        * @brief 写父类公有数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  baseP  要写入的数据
        * @param @param[i]  reuseData  复用空间
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-15
        */
        bool writeDataObjectAndJunction(H5::Group &gp, Acoustics::FITKSEAAbstractJunction *baseP);

        /**
        * @brief 读父类公有数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  baseP  要写入的指针
        * @param @param[i]  reuseData  复用空间
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-15
        */
        bool readDataObjectAndJunction(H5::Group &gp, Acoustics::FITKSEAAbstractJunction *baseP);

        /**
        * @brief 创建Acoustics::FITKSEAJunUserDefStr 的hdf5 数据类型
        * @param @return  H5::CompType hdf5 自定义数据类型
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-16
        */
        H5::CompType createJunUserDefStrType();

        /**
        * @brief 创建Acoustics::FITKSEAunPointConStr 的hdf5 数据类型
        * @param @return  H5::CompType hdf5 自定义数据类型
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-16
        */
        H5::CompType createJunPointConStrType();


        /**
        * @brief 创建Acoustics::FITKSEAunLineConStr 的hdf5 数据类型
        * @param @return  H5::CompType hdf5 自定义数据类型
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-16
        */
        H5::CompType createJunLineConStrType();

        /**
        * @brief 创建Acoustics::FITKSEAunAreaConStr 的hdf5 数据类型
        * @param @return  H5::CompType hdf5 自定义数据类型
        * @author yangjing (1195810980@qq.com)
        * @date 2024-1-16
        */
        H5::CompType createJunAreaConStrType();


    private:
        H5::CompType m_JunUserDefStrType;    
        H5::CompType m_JunPointConStrType;//点连接信息类型结构
        H5::CompType m_JunLineConStrType;//线连接信息类型结构
        H5::CompType m_JunAreaConStrType;//面连接信息类型结构
       

        Acoustics::FITKJunctionManager*m_JunctionManagerP = nullptr;
        IO::FITKHDF5FileTool*m_toolp{ nullptr };
    };
    Register2FITKIOAdaptorFactory(FITKAcousticsHDF5, Acoustics::FITKJunctionManager, FITKAcousticsSEAJunctionMgrAdaptor);
}
#endif
